<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    ul {
      display: flex;
      list-style: none;
    }

    li {
      cursor: pointer;
      margin-right: 10px;
    }

    .active {
      background-color: skyblue;
      border: 1px solid #000;
    }
  </style>
</head>

<body>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.js"></script>
  <div id="box">
    {{content}}
    <button v-show="index1>0" @click="index1--">上一个</button>
    <button v-show="index1<7" @click="index1++">下一个</button>
    <br>
    <button @click="btn1">上一个</button>
    <button @click="btn2">下一个</button>
    <ul>
      <!--判断每个li的下标是否和index1一致;如果不传参数,可以获取到事件对象,如果传了参数,就获取不到,需要用到关键字$event-->
      <li v-for="(item,index) in srcArr" :key="item.id" @mouseenter="btn(index,$event)" :class="index===index1?a:''" :data-id="index">
        <img width="80px" :src="item" alt="">
      </li>
    </ul>
    <img class="img" :src="srcArr[index1]" alt="">
  </div>
  <script>
    new Vue({
      el: '#box',
      data: {
        content: 'hello Vue',
        srcArr: [
          "./img/10-01.png",
          "./img/10-02.png",
          "./img/11-00.gif",
          "./img/11-01.gif",
          "./img/11-02.gif",
          "./img/11-03.gif",
          "./img/11-04.png",
          "./img/11-05.png",
        ],
        index1: 0,
        a: 'active'
      },
      methods: {
        btn(picnum, e) {
          console.log(e);
          this.index1 = picnum
        },
        btn1() {
          this.index1--
          if (this.index1 < 0) {
            this.index1 = 7
          }
        },

        btn2() {
          this.index1++
          if (this.index1 >= 8) {
            this.index1 = 0
          }
        },
      },

    })

  </script>
</body>

</html>